package com.sicpa.system.service.impl;

import com.sicpa.common.core.domain.entity.AssuranceBusinessDataReport;
import com.sicpa.common.core.domain.entity.AssuranceBusinessDataReportTemp;
import com.sicpa.common.utils.JsonUtil;
import com.sicpa.common.utils.SecurityUtils;
import com.sicpa.system.mapper.AssuranceBusinessDataReportTempMapper;
import com.sicpa.system.service.IAssuranceBusinessDataReportTempService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * AssuranceBusinessDataReportTempServiceImpl
 * @author lwf
 */
@Service
public class AssuranceBusinessDataReportTempServiceImpl implements IAssuranceBusinessDataReportTempService {

    private AssuranceBusinessDataReportTempMapper assuranceBusinessDataReportTempMapper;

    @Autowired
    public AssuranceBusinessDataReportTempServiceImpl(AssuranceBusinessDataReportTempMapper assuranceBusinessDataReportTempMapper) {
        this.assuranceBusinessDataReportTempMapper = assuranceBusinessDataReportTempMapper;
    }

    /**
     * 添加事务所鉴证业务备份数据
     * @param report
     * @return
     */
    @Override
    public Integer add(AssuranceBusinessDataReport report){
        AssuranceBusinessDataReportTemp reportTemp = new AssuranceBusinessDataReportTemp();
        String reportJson = JsonUtil.toJson(report);
        reportTemp.setJson(reportJson);
        Long userId = SecurityUtils.getLoginUser().getUser().getUserId();
        reportTemp.setCreateBy(userId);
        reportTemp.setBussinessId(report.getBusinessId());
        assuranceBusinessDataReportTempMapper.insertSelective(reportTemp);
        return reportTemp.getTempId();
    }
}
